﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using System.Web.UI.WebControls;
namespace JumbotCms.Extends.Search
{
    public partial class _index : JumbotCms.API.FrontHtml
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckExtendState("Search");
            Server.ScriptTimeout = 8;//脚本过期时间
            int CurrentPage = Int_ThisPage();
            string ContentStr = LoadPlugin_Search(6, CurrentPage, q("type"), Str2Str(q("ch")), q("k"));
            Response.Write(ContentStr);//直接输出
        }
        //<summary>
        //生成搜索页
        //</summary>
        //<param name="PSize">每页记录数</param>
        //<param name="page">页码</param>
        //<param name="ccType">频道类型</param>
        //<param name="ccid">频道id</param>
        //<param name="keys">关键字</param>
        //<returns></returns>
        private string LoadPlugin_Search(int PageSize, int CurrentPage, string ccType, string ccId, string keys)
        {
            string PageStr = string.Empty;
            PageStr = Jumbot.Common.DirFile.ReadFile(site.Dir + "extends/search/templates/index.htm");
            //过滤特殊字符
            keys = Jumbot.Common.Strings.FilterSymbol(keys);
            //去除多余空格
            keys = System.Text.RegularExpressions.Regex.Replace(keys, "\\s{2,}", " ");
            ReplaceSiteTags(ref PageStr);
            PageStr = PageStr.Replace("{$Keywords}", keys);
            PageStr = PageStr.Replace("{$PageSize}", PageSize.ToString());
            PageStr = PageStr.Replace("{$CurrentPage}", CurrentPage.ToString());
            PageStr = PageStr.Replace("{$ChannelType}", ccType);
            PageStr = PageStr.Replace("{$ChannelId}", ccId);
            return PageStr;
        }
    }
}
